﻿
<%@ Page language="vb" Inherits="PubProject.datafieldproperties" CodeBehind="datafieldproperties.aspx.vb" AutoEventWireup="false" %>
<%@ Register TagPrefix="cnt" Namespace="Microsoft.Crm.Application.Controls" Assembly="Microsoft.Crm.Application.Components.Application" %>
<html>
<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"/>
<title>Data Field Values</title>
<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/dialogs.css">
<style>

	BUTTON.edit
	{
		margin-bottom:	5px;
		width:			100px;
	}

</style>
<script language="javascript" src="/_common/scripts/global.js"></script>
<script language="javascript" src="/_controls/util/util.js"></script>
<script language="javascript" src="/Tools/EmailTemplateEditor/Scripts/datafields.js"></script>
<script language="javascript" src="/Tools/EmailTemplateEditor/Scripts/objects.js"></script>
<script language="javascript">

	var _oXml;
	
	function window.onload()
	{
		_oXml = window.dialogArguments.Xml;
		
		AddDataValues(window.dialogArguments.Text);
	}
	
	
	function document.onkeydown()
	{
		if (event.srcElement.tagName != "BUTTON" && event.keyCode == 13)
		{
			event.returnValue = false;

			Ok();
		}
		else if (event.keyCode == 116)
		{
			event.keyCode =0;
			event.returnValue = false;	
		}
	}


	function Ok()
	{
		var sDataSlug = "{!";
		
		var oRows = DataFields.firstChild.rows;

		var iLen = oRows.length;
		
		if (oRows.length > 1)
		{
			var i;
		
			for (i = 1; i < iLen; i++)
			{
				sDataSlug += oRows[i].value + ";";
			}

			if ((crmDialog.DefaultText.value.search(/[;&<>{}]/g) != -1))
			{
				alert ( "The default text field cannot contain any of the following characters: " + "\n\n ; & < > { }\n\n" +  "Remove any that are used and try again." );
				crmDialog.DefaultText.select();
			}
			else
			{
				sDataSlug += crmDialog.DefaultText.value + "}";
		
				window.returnValue = sDataSlug;
				window.close();
			}
		}
		else
		{
			alert( "You must have at least one data field value." );
		}
	}

</script>
</head>
<body>
<form name="crmDialog">
	<table border="0" cellspacing="0" cellpadding="8" width="100%" height="100%">
		<tr>
			<td class="header">
				<div class="header">Data Field Values</div>
				<div class="headerdesc">Configure the values to use for this data field.</div>
			</td>
		</tr>
		<tr>
			<td class="main">
				<table width="100%" height="100%" cellspacing="0" cellpadding="0">
					<tr height="25">
						<td>
							<cnt:AppTabBar id="crmTabBar" runat="server"/>
						</td>
					</tr>
					<tr>
						<td>
							<div id="tab0" class="tab">
								<fieldset>
									<legend>Data Field Values&nbsp;</legend>
									<div class="desc" style="padding-bottom: 5px;">
										Values will be used in the order they appear in the list below.
									</div>
									<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
										<col><col width="100">
										<tr>
											<td valign="top">
												<div id="DataFields" style="background: #ffffff; height: 115px; width: 180px; border: 1px solid #7b9ebd; overflow-y: auto; overflow-x: hidden;">
													<table cellpadding="2" cellspacing="0" width="100%">
														<tr style="display: none;">
															<td class="hand"></td>
														</tr>
													</table>
												</div>
											</td>
											<td valign="top">
												<button class="edit" onclick="MoveUp();">Move Up</button>
												<button class="edit" onclick="MoveDown();">Move Down</button>
												<button class="edit" onclick="Edit();">Edit</button>
												<button class="edit" onclick="Add();">Add</button>
												<button class="edit" onclick="Delete();">Delete</button>
											</td>
										</tr>
									</table>
									<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
										<col width="80"><col>
										<tr>
											<td>Default Text</td>
											<td>
												<input name="DefaultText" type="text" maxlength="500">
											</td>
										</tr>
									</table>
								</fieldset>
							</div>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="buttons">
				<button id="btnDialogOk" onclick="Ok();">OK</button>
				<span>&nbsp;</span>
				<button id="btnDialogCancel" onclick="window.close();">Cancel</button>
			</td>
		</tr>
	</table>
</form>
</body>
</html>
